package com.auto.oa.org.service.impl;

import java.util.List;
import java.util.Map;

import com.auto.oa.org.dao.OaOrgDAOFactory;
import com.auto.oa.org.domain.OaOrgArea;
import com.auto.oa.org.service.IOaOrgAreaService;
import com.system.common.Page;
import com.system.util.BeanUtil;

public class OaOrgAreaServiceImpl implements IOaOrgAreaService {
	
	public List<OaOrgArea> queryTreeOaOrgArea(OaOrgArea bean) throws Exception {
		Map<String, Object> param = BeanUtil.convertBeanToMap(bean);
		List<OaOrgArea> resultList = OaOrgDAOFactory.oaOrgAeaDAO.queryList(param);
		
		return resultList;
	}

	public List<OaOrgArea> queryPageListOaOrgArea(OaOrgArea bean, Page page) throws Exception{
		Map<String, Object> param = BeanUtil.convertBeanToMap(bean);
		List<OaOrgArea> resultList = OaOrgDAOFactory.oaOrgAeaDAO.queryList(param, page);
		
		return resultList;
	}
	
	public List<OaOrgArea> queryListOaOrgArea(OaOrgArea bean) throws Exception{
		Map<String, Object> param = BeanUtil.convertBeanToMap(bean);
		List<OaOrgArea> resultList = OaOrgDAOFactory.oaOrgAeaDAO.queryList(param);
		
		return resultList;
	}

	public boolean saveOrUpdateOaOrgArea(OaOrgArea bean) throws Exception {
		boolean bool = true;
		if(BeanUtil.isObjectNotNull(bean)){
			if(BeanUtil.isBlank(bean.getAuarGuid())){
				OaOrgDAOFactory.oaOrgAeaDAO.insertOaOrgArea(bean);
			}else{
				OaOrgDAOFactory.oaOrgAeaDAO.updateOaOrgArea(bean);
			}
		}else{
			bool = false;
		}
		
		return bool;
	}

	public boolean deleteOaOrgArea(String guid) throws Exception {
		boolean bool = true;
		if(!BeanUtil.isBlank(guid)){
			OaOrgDAOFactory.oaOrgAeaDAO.deleteOaOrgArea(guid);
		}else{
			bool = false;
		}
		
		return bool;
	}

	public OaOrgArea getOaOrgArea(String guid) throws Exception {
		OaOrgArea result = null;
		if(!BeanUtil.isBlank(guid)){
			result = OaOrgDAOFactory.oaOrgAeaDAO.loadOaOrgArea(guid);
		}
		
		return result;
	}

}
